const { defineConfig } = require('@vue/cli-service')

const path = require('path')

module.exports = defineConfig({
  transpileDependencies: true,
  devServer: {
    host: 'localhost',
    port: 8888,
    open: true,
    proxy: {
      // 所有 以 /conner开头请求 会触发这个反向代理
      '/api': {
        target: 'https://www.fastmock.site/mock/6c3417a0e6fd0056e5decf904c2152f9',
        // 是否切换源
        changeOrigin: true,
        // 请求前缀的路径重写
        pathRewrite: {
          '^/api': '/api'
        }
      }
    }
  },
  lintOnSave: false,
  chainWebpack: (config) => {
    config.resolve.alias
      .set('@', path.join(__dirname, 'src'))
      .set('@a', path.join(__dirname, 'src/api'))
      .set('@u', path.join(__dirname, 'src/utils'))
      .set('@r', path.join(__dirname, 'src/router'))
      .set('@v', path.join(__dirname, 'src/views'))
      .set('@s', path.join(__dirname, 'src/store'))
      .set('@c', path.join(__dirname, 'src/components'))
  }
})
